SRCS=$(wildcard *.cc)
TARGETS=$(patsubst %.cc,%,$(SRCS))
CXX=g++
CXXFLAGS=-g -O2
LDFLAGS=-ltorrent

all: $(TARGETS)

$(TARGETS): $(SRCS)
	$(CXX) $(CXXFLAGS) $@.cc -o$@ $(LDFLAGS)

test: all
	@for i in $(TARGETS); do \
		echo Running test $$i...;\
		./$$i;\
	done

clean:
	-rm -rf $(TARGETS)

